package com.example.gpssystem.repository;

import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.redis.core.RedisHash;

import java.time.LocalDateTime;

@Document(collection = "logistics_events") // 保留MongoDB注解
@RedisHash(value = "LogisticsEvent", timeToLive = 3600) // 添加Redis过期时间配置
@Data
public class LogisticsEvent {
    private  String description;
    @Id
    private String id;
    private String orderId;
    private LocalDateTime timestamp;
    @NotBlank
    private String location;  // 新增位置字段
    @NotBlank
    private String operatorId; // 操作员ID
    @NotBlank
    private String courierId; // 新增配送员ID字段
    
    // 修改构造方法
    public LogisticsEvent(String orderId, String description, String location, String operatorId, String courierId) {
        this.orderId = orderId;
        this.description = description;
        this.location = location;
        this.operatorId = operatorId;
        this.timestamp = LocalDateTime.now();
        this.courierId = courierId;
    }
    
    // 新增getter/setter
}
